<div class="eject_con">
  <div id="warning" class="alert alert-error"></div>
  <form method="post" target="_parent" action="index.php?s=seller/store/brand_save" enctype="multipart/form-data" id="brand_apply_form">
    <input type="hidden" name="form_submit" value="ok" />
    <input type="hidden" name="id" value="{$brand_info.id}" />
    <dl>
      <dt><i class="required">*</i>品牌名称：</dt>
      <dd>
        <input type="text" class="text" name="name" value="{$brand_info.name}" id="name" />
      </dd>
    </dl>
    <dl>
      <dt><i class="required">*</i>名称首字母：</dt>
      <dd>
        <input type="text" class="text" name="initial" value="{$brand_info.initial}" id="initial" />
      </dd>
    </dl>
    <dl>
      <dt>品牌类别：</dt>
      <dd id="gcategory">
        <input type="hidden" value="{$brand_info.class_id}" name="class_id" class="mls_id">
        <input type="hidden" value="{$brand_info.class_name}" name="class_name" class="mls_name">
        <span>{$brand_info.class_name}</span>
        <input class="edit_gcategory" type="button" value="编辑">
        <select style="display:none;">
          <option value="0">请选择</option>
          {if(!empty($goods_class))}
          {volist name="goods_class" id="val"}
          <option value="{$val.id}">{$val.name}</option>
          {/volist}
          {/if}
        </select>
      </dd>
    </dl>
    <dl>
      <dt><i class="required">*</i>品牌图标：</dt>
      <dd>
        <div class=""><span class="sign"><img alt="品牌图标：" src="/uploads/{$brand_info.pic}" height='50' onload="javascript:DrawImage(this,150,50)" nc_type="logo1"/></span></div>
        <div class="ncsc-upload-btn"> <a href="javascript:void(0);"><span>
          <input type="file" hidefocus="true" size="1" class="input-file" name="pic" id="pic" nc_type="logo"/>
          </span>
          <p><i class="icon-upload-alt"></i>图片上传</p>
          </a> </div>
        <p class="hint">建议上传大小为150x50的品牌图片。
申请品牌的目的是方便买家通过品牌索引页查找商品，申请时请填写品牌所属的类别，方便平台归类。在平台审核前，您可以编辑或撤销申请。</p>
      </dd>
    </dl>
    <div class="bottom">
      <label class="submit-border"><input type="submit" class="submit" value="提交"/></label>
    </div>
  </form>
</div>
<script>
$(function(){
	$.getScript('/old/data/resource/js/common_select.js', function(){
		gcategoryInit('gcategory');
	});

    jQuery.validator.addMethod("initial", function(value, element) {
        return /^[A-Za-z0-9]$/i.test(value);
    }, "");
    $('#brand_apply_form').validate({
        errorLabelContainer: $('#warning'),
        invalidHandler: function(form, validator) {
               $('#warning').show();
        },
    	submitHandler:function(form){
    		ajaxpost('brand_apply_form', '', '', 'onerror') 
    	},
        rules : {
            name : {
                required : true,
                rangelength: [0,100]
            },
            initial : {
                initial  : true
            }
			{if(empty($brand_info))}
			,
            pic : {
                required : true
			}
			{/if}
        },
        messages : {
            name : {
                required : '<i class="icon-exclamation-sign"></i>请填写品牌名称',
                rangelength: '<i class="icon-exclamation-sign"></i>品牌名称长度为0~100'
            },
            initial : {
                initial : '<i class="icon-exclamation-sign"></i>请填写正确首字母',
            }
            {if(empty($brand_info))}
			,
            pic : {
                required : '<i class="icon-exclamation-sign"></i>品牌图片不能为空'
			}
			{/if}
        }
    });
	$('input[nc_type="logo"]').change(function(){
		var src = getFullPath($(this)[0]);
		$('img[nc_type="logo1"]').attr('src', src);
	});
});

</script> 
